package com.xywy.tangandroid.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.xywy.tangandroid.R;
import com.xywy.tangandroid.base.BasicAdapter;
import com.xywy.tangandroid.util.Constant;

public class FoodSetTimeAdapter extends BasicAdapter<String> {
	private Context context;
	private List<String> list1;
	private LayoutInflater inflater;
	private setText view;

	public FoodSetTimeAdapter(Context context, List<String> list) {
		super(context, list);
		this.context = context;
		this.list1 = list;
		this.inflater = LayoutInflater.from(context);
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		viewholder holder = new viewholder();
		convertView = inflater.inflate(R.layout.item_test_blood_popwindow, null);
		holder.title = (TextView) convertView
				.findViewById(R.id.province);
		holder.title.setText(list1.get(position));
		
		
		
		convertView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				view.setText().setText(list1.get(position));
				
				if (view.dismisspoppwindow()!=null&&view.dismisspoppwindow().isShowing()) {
					view.dismisspoppwindow().dismiss();
					Constant.flag_blood = true;
				}
			}
		});
		return convertView;
	}
	
	
	public void setView(setText view) {
		this.view = view;
	}
	public interface setText{
		public TextView setText();
		 public PopupWindow  dismisspoppwindow();
	}
	private class viewholder {
		TextView title;
	}
}
